package com.boxtelecom.signe;

import java.util.ArrayList;
import java.util.Iterator;

import com.boxtelecom.users.FacebookUser;

public class ListAstro {
	private ArrayList<FacebookUser> _list_astro;
	
	public ListAstro(){
		_list_astro = new ArrayList<FacebookUser>();
		
	}
		
	public void sortBySigne(){
		
		Iterator<FacebookUser> it = _list_astro.iterator();
		
		ArrayList<FacebookUser> belier = null;
		ArrayList<FacebookUser> taureau = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> gemeaux = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> cancer = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> lion = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> vierge = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> balance = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> scorpion = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> sagittaire = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> capricorne = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> verseau = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> poisson = new ArrayList<FacebookUser>();
		ArrayList<FacebookUser> none = new ArrayList<FacebookUser>();
		
		while(it.hasNext()){
			FacebookUser user = it.next();
			
			if(user.getSigneAstro().equals("belier")){
				if(belier == null){
					belier = new ArrayList<FacebookUser>();
				}
				belier.add(user);
			}
			if(user.getSigneAstro().equals("taureau")){
				if(taureau == null){
					taureau = new ArrayList<FacebookUser>();
				}
				taureau.add(user);
			}
			if(user.getSigneAstro().equals("gemeaux")){
				if(gemeaux == null){
					gemeaux = new ArrayList<FacebookUser>();
				}
				gemeaux.add(user);
			}
			if(user.getSigneAstro().equals("cancer")){
				if(cancer == null){
					cancer = new ArrayList<FacebookUser>();
				}
				cancer.add(user);
			}
			if(user.getSigneAstro().equals("lion")){
				if(lion == null){
					lion = new ArrayList<FacebookUser>();
				}
				lion.add(user);
			}
			if(user.getSigneAstro().equals("vierge")){
				if(vierge == null){
					vierge = new ArrayList<FacebookUser>();
				}
				vierge.add(user);
			}
			if(user.getSigneAstro().equals("balance")){
				if(balance == null){
					balance = new ArrayList<FacebookUser>();
				}
				balance.add(user);
			}
			if(user.getSigneAstro().equals("scorpion")){
				if(scorpion == null){
					scorpion = new ArrayList<FacebookUser>();
				}
				scorpion.add(user);
			}
			if(user.getSigneAstro().equals("sagittaire")){
				if(sagittaire == null){
					sagittaire = new ArrayList<FacebookUser>();
				}
				sagittaire.add(user);
			}
			if(user.getSigneAstro().equals("capricorne")){
				if(capricorne == null){
					capricorne = new ArrayList<FacebookUser>();
				}
				capricorne.add(user);
			}
			if(user.getSigneAstro().equals("verseau")){
				if(verseau == null){
					verseau = new ArrayList<FacebookUser>();
				}
				verseau.add(user);
			}
			if(user.getSigneAstro().equals("poisson")){
				if(poisson == null){
					poisson = new ArrayList<FacebookUser>();
				}
				poisson.add(user);
			}
			if(user.getSigneAstro().equals("null")){
				if(none == null){
					none = new ArrayList<FacebookUser>();
				}
				none.add(user);
			}		
		}
		
		_list_astro.clear();
		
		if(belier != null){
			_list_astro.addAll(belier);
		}
		
		if(taureau != null){
			_list_astro.addAll(taureau);
		}
		if(gemeaux != null){
			_list_astro.addAll(gemeaux);
		}
		if(cancer != null){
			_list_astro.addAll(cancer);
		}
		if(lion != null){
			_list_astro.addAll(lion);
		}
		if(vierge != null){
			_list_astro.addAll(vierge);
		}
		if(balance != null){
			_list_astro.addAll(balance);
		}
		if(scorpion != null){
			_list_astro.addAll(scorpion);
		}
		if(sagittaire != null){
			_list_astro.addAll(sagittaire);
		}
		if(capricorne != null){
			_list_astro.addAll(capricorne);
		}
		if(verseau != null){
			_list_astro.addAll(verseau);
		}
		if(poisson != null){
			_list_astro.addAll(poisson);
		}
		if(none != null){
			_list_astro.addAll(none);
		}
	}

	public void add(FacebookUser user) {
		// TODO Auto-generated method stub
		_list_astro.add(user);
	}

	public ArrayList<FacebookUser> getList() {
		// TODO Auto-generated method stub
		return _list_astro;
	}
		
}
